﻿Imports System
Imports System.IO
Imports System.Runtime.Serialization
Imports System.Runtime.Serialization.Formatters.Binary

<Serializable()> Public Class ProjOutPuts
    Implements ICloneable

    Private m_Rectable As New Rectable '接受点最高值选项
    Private m_MaxTable As New MaxTable  '前n大值
    Private m_GridMaxAnalisis As Boolean = False '网格点高值分布
    Private m_DayTable As Boolean = False '输出所有指定时间同时发生的浓度
    Private m_ArrayPostFile(-1) As PostFile  '输出所有指定时间同时发生的浓度
    Private m_ArrayMaxiFile(-1) As MaxiFile '输出极大值文件 

    Private m_PostCareFile As New PostFile '通过这个选项来输出关心点的同时发生的浓度，以便于分析关心点的超标概率和超标最大持续时间
    ''' <summary>
    ''' 接受点最高值选项
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Property Rectable() As Rectable
        Get
            Return Me.m_Rectable
        End Get
        Set(ByVal value As Rectable)
            Me.m_Rectable = value
        End Set
    End Property
    
    ''' <summary>
    ''' 是否分析网格点高值分布
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Property GridMaxAnalisis() As Boolean
        Get
            Return m_GridMaxAnalisis
        End Get
        Set(ByVal value As Boolean)
            m_GridMaxAnalisis = value
        End Set
    End Property
    ''' <summary>
    ''' 前n大值列表
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Property MaxTable() As MaxTable
        Get
            Return m_MaxTable
        End Get
        Set(ByVal value As MaxTable)
            m_MaxTable = value
        End Set
    End Property
    ''' <summary>
    ''' 输出所有指定时间同时发生的浓度
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Property DayTable() As Boolean
        Get
            Return m_DayTable
        End Get
        Set(ByVal value As Boolean)
            m_DayTable = value
        End Set
    End Property
    ''' <summary>
    ''' 输出同时发生的结果对于每一个接受点
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Property ArrayPostFile() As PostFile()
        Get
            Return m_ArrayPostFile
        End Get
        Set(ByVal value As PostFile())
            m_ArrayPostFile = value
        End Set
    End Property
    Property PostCareFile() As PostFile '通过这个选项来输出关心点的同时发生的浓度，以便于分析关心点的超标概率和超标最大持续时间
        Get
            Return m_PostCareFile
        End Get
        Set(ByVal value As PostFile)
            m_PostCareFile = value
        End Set
    End Property
    ''' <summary>
    ''' 输出极大值文件
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Property ArrayMaxiFile() As MaxiFile()
        Get
            Return m_ArrayMaxiFile
        End Get
        Set(ByVal value As MaxiFile())
            m_ArrayMaxiFile = value
        End Set
    End Property

    ''' <summary>
    ''' 重新设置输出文件
    ''' </summary>
    ''' <param name="AllPolluts"></param>
    ''' <param name="AerageingTime"></param>
    ''' <param name="GroupsCollection"></param>
    ''' <remarks></remarks>
    Public Sub ReSetOutPutFile(ByVal AllPolluts As AllPolluts, ByVal AerageingTime As AerageingTime, ByVal GroupsCollection As GroupsCollection)
        If Me.m_ArrayMaxiFile.Length > 0 Then
            Dim AMaxiFile(-1) As MaxiFile
            For i As Integer = 0 To AllPolluts.AllSelectPollut.Length - 1
                For j As Integer = 0 To GroupsCollection.Count - 1
                    For k As Integer = 0 To AerageingTime.GetSelectedAerageingTime.Length - 1
                        For L As Integer = 0 To Me.m_ArrayMaxiFile.Length - 1
                            If AllPolluts.AllSelectPollut(i).Name = Me.m_ArrayMaxiFile(L).PolluteName _
                            And GroupsCollection.Item(j).Name = Me.m_ArrayMaxiFile(L).GroupName _
                            And AerageingTime.GetSelectedAerageingTime(k) = Me.m_ArrayMaxiFile(L).AervarageTime Then
                                ReDim Preserve AMaxiFile(AMaxiFile.Length)
                                AMaxiFile(AMaxiFile.Length - 1) = New MaxiFile
                                AMaxiFile(AMaxiFile.Length - 1) = Me.m_ArrayMaxiFile(L).Clone
                            End If
                        Next
                    Next
                Next
            Next
            Me.m_ArrayMaxiFile = AMaxiFile
        End If

        If Me.m_ArrayPostFile.Length > 0 Then
            Dim APostFile(-1) As PostFile
            For i As Integer = 0 To AllPolluts.AllSelectPollut.Length - 1
                For j As Integer = 0 To GroupsCollection.Count - 1
                    For k As Integer = 0 To AerageingTime.GetSelectedAerageingTime.Length - 1
                        For L As Integer = 0 To Me.m_ArrayPostFile.Length - 1
                            If AllPolluts.AllSelectPollut(i).Name = Me.m_ArrayPostFile(L).PolluteName _
                            And GroupsCollection.Item(j).Name = Me.m_ArrayPostFile(L).GroupName _
                            And AerageingTime.GetSelectedAerageingTime(k) = Me.m_ArrayPostFile(L).AervarageTime Then
                                ReDim Preserve APostFile(APostFile.Length)
                                APostFile(APostFile.Length - 1) = New PostFile
                                APostFile(APostFile.Length - 1) = Me.m_ArrayPostFile(L).Clone
                            End If
                        Next
                    Next
                Next
            Next
            Me.m_ArrayPostFile = APostFile
        End If
    End Sub

 

    Public Function Clone() As Object Implements System.ICloneable.Clone
        Dim obj As New ProjOutPuts
        obj.m_Rectable = Me.m_Rectable.Clone '接受最高值选项
        obj.m_MaxTable = Me.m_MaxTable
        obj.m_GridMaxAnalisis = Me.m_GridMaxAnalisis '网格点高值分布
        ReDim obj.m_ArrayPostFile(Me.m_ArrayPostFile.Length - 1)
        For i As Integer = 0 To Me.m_ArrayPostFile.Length - 1
            obj.m_ArrayPostFile(i) = Me.m_ArrayPostFile(i).Clone
        Next
        obj.m_DayTable = Me.m_DayTable  '输出所有指定时间同时发生的浓度
        obj.m_PostCareFile = Me.m_PostCareFile.Clone '关心点同时发生的浓度
        ReDim obj.m_ArrayMaxiFile(Me.m_ArrayMaxiFile.Length - 1)
        For i As Integer = 0 To Me.m_ArrayMaxiFile.Length - 1
            obj.m_ArrayMaxiFile(i) = Me.m_ArrayMaxiFile(i).Clone
        Next
        Return obj
    End Function
End Class
